#include "qlcdnumberhost.h"

#include "qabstractproperty.h"
#include "qpropertyfactory.h"
#include "qcommonstruct.h"

#include <QLCDNumber>

using namespace SHAREDLIB;

QLCDNumberHost::QLCDNumberHost(QObject *object):
    QFrameHost(object)
{
    QAbstractProperty *pro;

    pro=QPropertyFactory::createProperty("Number");
    if(pro!=NULL)
    {
        pro->setAttribute("name","digitCount");
        pro->setAttribute("property_name",tr("DigitCount"));
        pro->setAttribute("group","Attributes");
        addProperty(pro);
    }

    pro=QPropertyFactory::createProperty("Number");
    if(pro!=NULL)
    {
        pro->setAttribute("name","numDigits");
        pro->setAttribute("property_name",tr("NumDigits"));
        pro->setAttribute("group","Attributes");
        addProperty(pro);
    }

    pro=QPropertyFactory::createProperty("Number");
    if(pro!=NULL)
    {
        pro->setAttribute("name","intValue");
        pro->setAttribute("property_name",tr("IntValue"));
        pro->setAttribute("group","Attributes");
        addProperty(pro);
    }

    pro=QPropertyFactory::createProperty("Float");
    if(pro!=NULL)
    {
        pro->setAttribute("name","value");
        pro->setAttribute("property_name",tr("Value"));
        pro->setAttribute("group","Attributes");
        addProperty(pro);
    }

    pro=QPropertyFactory::createProperty("Enum");
    if(pro!=NULL)
    {
        pro->setAttribute("name","mode");
        pro->setAttribute("property_name",tr("Mode"));
        pro->setAttribute("group","Attributes");
        ComboItems items;
        tagComboItem item;

        item.m_text=tr("Hex");
        item.m_value=QLCDNumber::Hex;
        items.append(item);

        item.m_text=tr("Dec");
        item.m_value=QLCDNumber::Dec;
        items.append(item);

        item.m_text=tr("Oct");
        item.m_value=QLCDNumber::Oct;
        items.append(item);

        item.m_text=tr("Bin");
        item.m_value=QLCDNumber::Bin;
        items.append(item);

        QVariant v;
        v.setValue<ComboItems>(items);
        pro->setAttribute("items",v);

        addProperty(pro);
    }

    pro=QPropertyFactory::createProperty("Enum");
    if(pro!=NULL)
    {
        pro->setAttribute("name","segmentStyle");
        pro->setAttribute("property_name",tr("SegmentStyle"));
        pro->setAttribute("group","Attributes");
        ComboItems items;
        tagComboItem item;

        item.m_text=tr("Outline");
        item.m_value=QLCDNumber::Outline;
        items.append(item);

        item.m_text=tr("Filled");
        item.m_value=QLCDNumber::Filled;
        items.append(item);

        item.m_text=tr("Flat");
        item.m_value=QLCDNumber::Flat;
        items.append(item);

        QVariant v;
        v.setValue<ComboItems>(items);
        pro->setAttribute("items",v);

        addProperty(pro);
    }

    appendMemery("intValue");
    appendMemery("value");
}

void QLCDNumberHost::setIntValue(int intValue)
{
    setPropertyValue("intValue",intValue);
}

int QLCDNumberHost::intValue()
{
    return getPropertyValue("intValue").toInt();
}

void QLCDNumberHost::setValue(float value)
{
    setPropertyValue("value",value);
}

float QLCDNumberHost::value()
{
    return getPropertyValue("value").toFloat();
}

void QLCDNumberHost::setMode(int mode)
{
    setPropertyValue("mode",mode);
}

int QLCDNumberHost::mode()
{
    return getPropertyValue("mode").toInt();
}

void QLCDNumberHost::setSegmentStyle(int segmentStyle)
{
    setPropertyValue("segmentStyle",segmentStyle);
}

int QLCDNumberHost::segmentStyle()
{
    return getPropertyValue("segmentStyle").toInt();
}

void QLCDNumberHost::setDigitCount(int digitCount)
{
    setPropertyValue("digitCount",digitCount);
}

int QLCDNumberHost::digitCount()
{
    return getPropertyValue("digitCount").toInt();
}

void QLCDNumberHost::setNumDigits(int numDigits)
{
    setPropertyValue("numDigits",numDigits);
}

int QLCDNumberHost::numDigits()
{
    return getPropertyValue("numDigits").toInt();
}

